package middle.day01;

public class ReverseList {
    public static class Node{
        public int value;
        public Node next;
        public Node(int data){
            value = data;
        }
    }
    public static class DoubleNode{
        public int value;
        public DoubleNode pre;
        public DoubleNode next;
        public DoubleNode(int data){
            value = data;
        }
    }
    public static Node reverseList(Node head){
        Node pre = null;
        Node next = null;
        while(head != null){
            next = head.next;
            head.next = pre;
            pre = head;
            head = next;
        }
        return pre;
    }
    public static DoubleNode reverseList(DoubleNode head){
        DoubleNode pre = null;
        DoubleNode next = null;
        while(head != null){
           next = head.next;
           head.next = pre;
           head.pre = next;
           pre = head;
           head = next;
        }
        return pre;

    }

}
